package com.zhouwd.zplayer;

import android.media.AudioManager;
import android.media.AudioTrack;

public class AudioTrackManager {

    private AudioTrack audioTrack;

    public AudioTrackManager() {

    }

    public void init(int sampleRateInHz,int channelConfig,int audioFormat) {
        int bufferSizeInBytes = AudioTrack.getMinBufferSize(sampleRateInHz, channelConfig, audioFormat);
        audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, sampleRateInHz, channelConfig, audioFormat, bufferSizeInBytes, AudioTrack.MODE_STREAM);
    }

    public void write(byte[] data) {

        audioTrack.write(data, 0, data.length);

    }

}
